package Test;

import javax.swing.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

public class MyJFrame3 extends JFrame implements KeyListener {

    public MyJFrame3() {
        this.setSize(603, 680);

        this.setTitle("拼图游戏 V0.99");

        //置顶
        this.setAlwaysOnTop(true);

        //界面居中
        this.setLocationRelativeTo(null);

        //关闭模式
        this.setDefaultCloseOperation(3);

        //取消默认布局模式（居中） 取消后才是按XY布局的模式
        this.setLayout(null);

//给整个窗体添加鼠标事件
        this.addKeyListener(this);

        //按下按键如果一直不送 一直调用KeyPressed



        this.setVisible(true);

    }

    @Override
    public void keyTyped(KeyEvent e) {

    }

    @Override
    public void keyPressed(KeyEvent e) {
        System.out.println("按下不送");
    }

    @Override
    public void keyReleased(KeyEvent e) {
        System.out.println("松开");

        int code=e.getKeyCode();
        System.out.println(code);
    }
}
